package com.dropdb.demo.bean.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

@Data
public class BaseRespVO<T> {
    @JsonInclude(JsonInclude.Include.NON_NULL)
    T data;
    String errmsg;
    Integer errno;

    public static BaseRespVO ok(){
        BaseRespVO baseRespVo = new BaseRespVO();
        baseRespVo.setErrmsg("成功");
        baseRespVo.setErrno(0);
        return baseRespVo;
    }
    public static BaseRespVO ok(Object data){
        BaseRespVO baseRespVo = ok();
        baseRespVo.setData(data);
        return baseRespVo;
    }

    public static BaseRespVO error(Integer code, String message) {
        BaseRespVO baseRespVo = new BaseRespVO();
        baseRespVo.setErrmsg(message);
        baseRespVo.setErrno(code);
        return baseRespVo;
    }
}
